package com.whf.android.jar.util.battery;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.StringUtils;
import com.whf.android.jar.R;
import com.whf.android.jar.app.Latte;
import com.whf.android.jar.popup.LattePopupCenter;


/**
 * 电池优化
 *
 * @author qf
 * @version 1.0.3
 */
public class BatteryOptimizedPopup extends LattePopupCenter {


    @NonNull
    public static BatteryOptimizedPopup create() {
        return create(Latte.getActivity());
    }

    @NonNull
    public static BatteryOptimizedPopup create(Context context) {
        return new BatteryOptimizedPopup(context);
    }

    public BatteryOptimizedPopup(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int setLayout() {
        return R.layout.hai_battery_popup_optimized;
    }

    @Override
    protected void initViews() {
        String appName = StringUtils.getString(R.string.app_name);
        setText(R.id.id_text, "因手机系统限制，本程序桌面角标刷新等被异常关闭。请把" + appName + "设为受保护应用。");
        setOnClickListener(R.id.id_btn_cancel, new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mClickDecisionListener != null) {
                    mClickDecisionListener.onCancel();
                }
            }
        });
        setOnClickListener(R.id.id_btn_set, new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mClickDecisionListener != null) {
                    mClickDecisionListener.onConfirm(null);
                }
            }
        });
    }
}
